Skip to content

Conversation

jmdesprez
Copy link
Contributor

@jmdesprez jmdesprez commented Nov 25, 2024

PR to improve plugin's FIPS compliance. All the checks are centralized in FIPS140Utils to ensure consistency of error messages.

Bump of Jenkins is required to have access to FIPS140.useCompliantAlgorithms()

Testing done

See added unit tests. Here is also screenshots from the form validation:

image

image

image

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@jmdesprez
Copy link
Contributor Author

I'm fixing the unit test

@fcojfernandez fcojfernandez changed the title [JENKINS-74907] Improve FIPS compliance [JENKINS-74907] Add validations when Jenkins is in FIPS mode Nov 26, 2024
@fcojfernandez fcojfernandez added the enhancement Feature additions or enhancements label Nov 26, 2024
@jmdesprez jmdesprez marked this pull request as draft November 26, 2024 15:48
@jmdesprez
Copy link
Contributor Author

It's not possible to tests this because of non-compliant dependencies. So I'm moving this PR to draft.

# Conflicts:
#	pom.xml
#	src/main/java/hudson/plugins/ec2/EC2Cloud.java
#	src/main/java/hudson/plugins/ec2/WindowsData.java
#	src/main/java/hudson/plugins/ec2/ssh/verifiers/HostKey.java
#	src/main/java/hudson/plugins/ec2/win/WinConnection.java
#	src/main/java/hudson/plugins/ec2/win/winrm/WinRMClient.java
#	src/main/resources/hudson/plugins/ec2/Messages.properties
@jmdesprez jmdesprez marked this pull request as ready for review January 22, 2025 15:24
Comment on lines 32 to 41
try {
FIPS140Utils.ensureNoPasswordLeak(useHTTPS, password);
} catch (IllegalArgumentException e) {
throw new Descriptor.FormException(e, "password");
}
try {
FIPS140Utils.ensureNoSelfSignedCertificate(allowSelfSignedCertificate);
} catch (IllegalArgumentException e) {
throw new Descriptor.FormException(e, "allowSelfSignedCertificate");
}
Copy link
Member

@jtnord jtnord Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appears to be no check on the password length here if a password is in used? Also should the checks only take place if specifyPassword is true?

Copy link
Contributor Author

@jmdesprez jmdesprez Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added: bac89fb (see next commit)

Copy link
Contributor Author

@jmdesprez jmdesprez Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added: 93c5a3c

@jmdesprez jmdesprez requested a review from jtnord January 29, 2025 12:54
@jmdesprez jmdesprez marked this pull request as draft January 29, 2025 13:38
@jmdesprez
Copy link
Contributor Author

Moved to draft to avoid merging that before https://issues.jenkins.io/browse/JENKINS-75187 is fixed

Copy link

@pankajy-dev pankajy-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jmdesprez jmdesprez marked this pull request as ready for review January 30, 2025 13:29
Copy link

@PereBueno PereBueno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines 21 to 24
@Test(expected = IllegalArgumentException.class)
public void testSelfSignedCertificateNotAllowed() throws MalformedURLException {
new WinRMClient(new URL("https://localhost"), "username", "password", true);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT, the modern way of testing an expected exception is assertThrows(Throwable.class, () -> ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: 22bda8f

@fcojfernandez fcojfernandez merged commit f40220e into jenkinsci:master Jan 31, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature additions or enhancements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants